package com.boardour.toupin.show;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class ShowTextureView extends TextureView {
    public ShowTextureView(@NonNull Context context) {
        super(context);
    }

    public ShowTextureView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ShowTextureView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        // int screenWidth = DensityUtils.getScreenWidth();
        int screenHeight = MeasureSpec.getSize(heightMeasureSpec);
        float rate = 1920f / 1080f;
        int height = screenHeight;
        double w = height * rate + 0.5f; //
        setMeasuredDimension((int) w, height);
    }
}
